#include<cstdlib>
#include<cstdint>
#include<cstring>
#include<cstdio>
#include<iostream>

class testType{
private:
	int a;
	float b;
	double c;
	char d;
	uint16_t crc;
	
public:
	testType(){};
	testType(int a,float b,double c,char d,uint16_t f):a(a),b(b),c(c),d(d),crc(f){};
	
	void print(){
		printf("a:%d\nb:%f\nc:%lf\nd:%c\n%d",this->a,this->b,this->c,this->d,this->crc);
	}
};


int uartTransmit(){
	printf("串口发数据了\n");
	return 0;
}

class transmitData{
private:
	uint8_t *dataBuffer;
	int16_t bufferSize;
	
	
public:
	
	transmitData(){};
	~transmitData(){};
	
	int (*transmit)();
	void sendData(testType *a){
		bufferSize = sizeof(testType);
		memset(dataBuffer,0,bufferSize);
		memcpy(this->dataBuffer,(uint8_t *)a,this->bufferSize);
		(*transmit)();
	}
	
	testType receiveData(){
		testType rcvData;
		memcpy(&rcvData,(testType *)this->dataBuffer,this->bufferSize);
		return rcvData;
	}
};

int main(){
	std::cout<<sizeof(int);
	testType t1(1,1.33,2.334,'c',0);
	transmitData transtool;
	transtool.transmit=uartTransmit;
	transtool.sendData(&t1);
	testType t2=transtool.receiveData();
	t2.print();
}
